package com.ufgov.ip.base.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.ufgov.ip.base.dao.IPDictDao;
import com.ufgov.ip.base.dao.IPDictDetailDao;
import com.ufgov.ip.base.dao.IPRegionDao;
import com.ufgov.ip.base.entity.IpDictionary;
import com.ufgov.ip.base.entity.IpDictionaryDetail;
import com.ufgov.ip.base.entity.IpRegion;
import com.ufgov.ip.dao.IuapUserDao;
import com.ufgov.ip.entity.IpUser;
import com.ufgov.ip.entity.IpUserCompany;
import com.ufgov.ip.sysmanager.dao.IpUserCompanyDao;
import com.ufgov.ip.sysmanager.dao.IpUserRoleDao;
import com.ufgov.ip.sysmanager.entity.IpUserRole;

@Component
@Transactional(readOnly=true)
public class IPCommonService {

	@Autowired
	private IPDictDao iPDictDao;
	
	@Autowired
	private IPDictDetailDao iPDictDetailDao;
	
	@Autowired
	private IPRegionDao iPRegionDao;
	
	@Autowired
	private IuapUserDao userDao;
	
	@Autowired
	private IpUserCompanyDao ipUserCompanyDao;
	
	@Autowired
	private IpUserRoleDao ipUserRoleDao;
	
	
	public IuapUserDao getUserDao() {
		return userDao;
	}
	public IpUserCompanyDao getIpUserCompanyDao() {
		return ipUserCompanyDao;
	}
	public IpUserRoleDao getIpUserRoleDao() {
		return ipUserRoleDao;
	}
	public IPRegionDao getiPRegionDao() {
		return iPRegionDao;
	}
	public void setiPRegionDao(IPRegionDao iPRegionDao) {
		this.iPRegionDao = iPRegionDao;
	}
	public IPDictDetailDao getiPDictDetailDao() {
		return iPDictDetailDao;
	}
	public void setiPDictDetailDao(IPDictDetailDao iPDictDetailDao) {
		this.iPDictDetailDao = iPDictDetailDao;
	}
	

	public IPDictDao getiPDictDao() {
		return iPDictDao;
	}
	public void setiPDictDao(IPDictDao iPDictDao) {
		this.iPDictDao = iPDictDao;
	}
	
	public IpDictionary findIpDictionaryByDicType(String dicType){
		return iPDictDao.findIpDictionaryByDicType(dicType);
	}
	
	public List<IpDictionaryDetail> findIpDictionaryDetailByDicId(String dicId){
		return iPDictDetailDao.findIpDictionaryDetailByDicId(dicId);
	}
	
	public List<IpRegion> findIpRegionByTheCodeLike(String theCode){
		return iPRegionDao.findIpRegionByTheCodeLike(theCode);
	}
	
	public IpRegion findIpRegionByTheCode(String theCode){
		return iPRegionDao.findIpRegionByTheCode(theCode);
	}
	
	@Transactional
	public void saveExcelInfo(IpUser ipUser,
			IpUserCompany ipUserCompany, IpUserRole ipUserRole) {
		
		userDao.save(ipUser);
		ipUserCompanyDao.save(ipUserCompany);
		ipUserRoleDao.save(ipUserRole);
		
		
		
	}
	
	
	
}
